#!/usr/bin/python

#Copyright 2012 Elias Farhan
#
#This file is part of Squirrel.
#
#Squirrel is free software: you can redistribute it and/or modify it under the terms of the GNU General 
#Public License as published by the Free Software Foundation, either version 3 of the License, or (at your 
#option) any later version.
#
#Squirrel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
#See the GNU General Public License for more details.

class Box():
	def __init__(self, origin, end):
		self.origin = origin
		self.end = end
		self.size = (end[0]-origin[0], end[1]-origin[1])
	def pointIsIn(self, point):
		return ((self.origin[0] <= point[0] <= self.end[0]) and (self.origin[1] <= point[1] <= self.end[1]))
	def squareIsIn(self, origin, end):
		return (self.pointIsIn(origin) or self.pointIsIn(end) or self.pointIsIn((origin[0], end[1])) or self.pointIsIn((end[0], origin[1])))
	def BoxIsIn(self, box):
		return (self.squareIsIn(box.origin, box.end) or box.squareIsIn(self.origin, self.end))
	def setPosition(self, origin, end):
		self.origin = origin
		self.end = end
